<?php
/**
 * 订单里的酒店信息
 * User: lxq
 * Date: 2018/4/2
 * Time: 11:45
 */
class order_hotelModel extends Model{

    public function __construct()
    {
        parent::__construct('order_hotel');
    }

    /**
     * 获取记录数组
     * @param array $condition
     * @param string $field
     * @param string $order
     * @return mixed
     */
    public function getOrderHotelList($condition = array(), $field = '*', $order = 'add_time desc'){
        return $this->field($field)->where($condition)->order($order)->select();
    }

    /**
     * 更新记录
     * @param array $condition
     * @param array $params
     * @return mixed
     */
    public function updateOrderHotel($condition, $params)
    {
        return $this->where($condition)->update($params);
    }

    /**
     * 插入一条记录
     * @param array $params
     * @return mixed
     */
    public function addOrderHotel($params)
    {
        return $this->insert($params);
    }


    /**
     * 获取一条记录的详细信息
     * @param array $condition
     * @param string $field
     * @return mixed
     */
    public function getOrderHotelInfo($condition = array(), $field = '*')
    {
        return $this->field($field)->where($condition)->find();
    }

    /**
     * 获取某个房型指定时间段的销售信息
     * @param array $condition
     */
    public function getOrderHoteloh_num($condition = array())
    {
        $field = 'spec_id,SUM(oh_num) AS sum_on_num ';
        return $this->where($condition)->field($field)->find();
    }

}